package com.nightlife.model.rbac;

import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.ForeignKey;
/**
 * 用户表
 * @author Z.x.Y
 *
 */
@Entity
@Table(name = "SYS_USER")
public class User {
	/**
	 * 用户ID
	 */
	@Id
	@GeneratedValue
	private int userId;
	/**
	 * 用户昵称
	 */
	@Column(length = 20)
	private String nickName;
	/**
	 * 用户名
	 */
	@Column(length = 20)
	private String userName;
	/**
	 * 密码
	 */
	@Column(length = 16)
	private String password;
	/**
	 * 创建时间
	 */
	private Date createTime;
	
	/**
	 * 用户/用户组关系
	 */
	@ManyToMany
	@ForeignKey(name="USER_GROUP_FK",inverseName="GROUP_USER_FK")
	@JoinTable(name = "SYS_USER_GROUP", joinColumns = { @JoinColumn(name = "userId") }, inverseJoinColumns = { @JoinColumn(name = "groupId") })
	private Set<Group> groups;
	
	public int getUserId() {
		return userId;
	}
	public void setUserId(int userId) {
		this.userId = userId;
	}
	public String getNickName() {
		return nickName;
	}
	public void setNickName(String nickName) {
		this.nickName = nickName;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	public Set<Group> getGroups() {
		return groups;
	}
	public void setGroups(Set<Group> groups) {
		this.groups = groups;
	}
}
